package entity;

import java.lang.reflect.InvocationTargetException;

public class EntityFactory<T> {

	private EntityRepository repository;

	public EntityFactory(EntityRepository repository) {
		this.repository = repository;
	}
	
	public Entity create(String name) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException  {
		Entity entity = Entity.class.getConstructor(String.class).newInstance(name);
		entity.entityRepository = repository;
		repository.store(entity);
		return entity;
	}
	
}
